﻿@model MaintenanceModel
@using Nop.Web.Framework.Localization

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)

<script>
    $(document).ready(function () {
        bindBootstrapTabSelectEvent('category-edit');
    });
</script>

<div class="content">
    <div class="form-horizontal">
        <div class="row">
            <div class="col-md-12 clearfix">
                <div class="pull-left">
                    @Html.Action("Mode", "Setting", new { modeName = "category-advanced-mode" })
                </div>
            </div>
        </div>
        <div id="category-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("tab-info", new LocalizedString("基本信息"), true)
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("tab-info", @TabInfo(), true)
            </div>
        </div>
    </div>
</div>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "category-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab name*@
<input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">

@helper TabInfo()
{
    <div class="content">
        <div class="form-horizontal">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-md-3">
                                报修单号
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.SNo)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                设施设备
                            </div>
                            <div class="col-md-9">
                                @Html.NopDisplayFor(model => model.EquipmentName)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                维修班组
                            </div>
                            <div class="col-md-9">
                                @Html.EditorFor(model => model.TeamId, new { SelectList = Model.AvailableDepartments })
                                @Html.ValidationMessageFor(model => model.TeamId)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                维修人
                            </div>
                            <div class="col-md-9">
                                @Html.NopDropDownListFor(model => model.PersonId, Model.AvailableUsers)
                                @Html.ValidationMessageFor(model => model.PersonId)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                维修时间
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.MaintenanceOn)
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-3">
                                维修备注
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.MaintenanceComment)
                                @Html.ValidationMessageFor(model => model.MaintenanceComment)
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function () {
    $("#@Html.FieldIdFor(model => model.TeamId)").change(function () {
        var selectedItem = $(this).val();
        var ddlStates = $("#@Html.FieldIdFor(model => model.PersonId)");
        $.ajax({
            cache: false,
            type: "GET",
            url: "@(Url.Action("GetUsersByDepartmentId", "Customer"))",
            data: { "departId": selectedItem },
            success: function(data) {
                ddlStates.html('');
                $.each(data, function(id, option) {
                    ddlStates.append($('<option></option>').val(option.id).html(option.name));
                });
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert('Failed to retrieve states.');
            }
        });
    });
});
    </script>
    
}
